home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 April: Mac OS SDK / Dev.CD Apr 97 SDK1.toast / Development Kits (Disc 1) / Apple Shared Library Manager / ASLM Examples / Example Tools / Sources / TTaskSchedulerExample.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-11-19  |  2.1 KB  |  93 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        TTaskSchedulerExample.h
  3.  
  4.     Contains:    Declaraton for TArcTAsk, a TOperation subclass. TOperation objects
  5.                 contain the implementation of the task to be performed. This operation
  6.                 is placed on a TTaskScheduler to be performed at each SystemTask time.
  7.                 TArcTask performs a drawing of an arc, from an angle 0 to 360 degrees.
  8.  
  9.     Copyright:    © 1993 by Apple Computer, Inc., all rights reserved.
  10.  
  11. */
  12.  
  13. #ifndef __TTASKSCHEDULEREXAMPLE__
  14. #define __TTASKSCHEDULEREXAMPLE__
  15.  
  16. #ifndef __DIALOGS__
  17. #include <Dialogs.h>
  18. #endif
  19.  
  20. #ifndef __FONTS__
  21. #include <Fonts.h>
  22. #endif
  23.  
  24. #ifndef __MEMORY__
  25. #include <memory.h>
  26. #endif
  27.  
  28. #ifndef __QUICKDRAW__
  29. #include <QuickDraw.h>
  30. #endif
  31.  
  32. #ifndef __RESOURCES__
  33. #include <Resources.h>
  34. #endif
  35.  
  36. #ifndef __TOOLUTILS__
  37. #include <ToolUtils.h>
  38. #endif
  39.  
  40. #ifndef __WINDOWS__
  41. #include <Windows.h>
  42. #endif
  43.  
  44. ///————————————————————————————————————————————————————————————————————————————————————
  45. ///    TArcTask
  46. ///————————————————————————————————————————————————————————————————————————————————————
  47.  
  48. class TArcTask : public TOperation {
  49.     public:
  50.                         TArcTask(WindowPtr, short arcAngle);// Constructor
  51.         virtual            ~TArcTask();    // Destructor
  52.         virtual void    Process();        // Override
  53.  
  54.     private:
  55.         WindowPtr        fWindow;        // pointer to our window record
  56.         short            fArcAngle;        // the actual arc angle
  57. };
  58.  
  59. ///————————————————————————————————————————————————————————————————————————————————————
  60. ///    TArcTask IMPLEMENTATION
  61. ///————————————————————————————————————————————————————————————————————————————————————
  62.  
  63.     TArcTask::TArcTask(WindowPtr theWindow, short arcAngle )
  64.     {
  65.         fWindow = theWindow;
  66.         fArcAngle = arcAngle % 360;
  67.     }
  68.  
  69.     TArcTask::~TArcTask()
  70.     {
  71.     }
  72.     
  73.     void TArcTask::Process()
  74.     {    
  75.         // draw the arc for this process
  76.         GrafPtr    oldport;
  77.         GetPort( &oldport );
  78.         SetPort( fWindow );
  79.         ShowWindow( fWindow );
  80.         if (fArcAngle == 0)
  81.             EraseRect( &fWindow->portRect );
  82.         PaintArc( &fWindow->portRect, 0, fArcAngle );
  83.         SetPort( oldport );
  84.         
  85.         // delay .01 seconds so we don't do things too fast
  86.         TStopwatch    stopwatch;
  87.         while( stopwatch.ElapsedMilliseconds() < 10 );
  88.         
  89.         delete this;                    // we are done 
  90.     }
  91.  
  92. #endif
  93.